/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.camachosanchez.bean;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Zully
 */
@Entity
@Table(name = "insumos_despinche")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "InsumosDespinche.findAll", query = "SELECT i FROM InsumosDespinche i"),
    @NamedQuery(name = "InsumosDespinche.findById", query = "SELECT i FROM InsumosDespinche i WHERE i.id = :id"),
    @NamedQuery(name = "InsumosDespinche.findByCodigo", query = "SELECT i FROM InsumosDespinche i WHERE i.codigo = :codigo"),
    @NamedQuery(name = "InsumosDespinche.findByNombre", query = "SELECT i FROM InsumosDespinche i WHERE i.nombre = :nombre"),
    @NamedQuery(name = "InsumosDespinche.findByEstado", query = "SELECT i FROM InsumosDespinche i WHERE i.estado = :estado")})
public class InsumosDespinche implements Serializable, Comparable<InsumosDespinche> {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Short id;
    @Basic(optional = false)
    @Column(name = "codigo")
    private int codigo;
    @Basic(optional = false)
    @Column(name = "nombre")
    private String nombre;
    @Basic(optional = false)
    @Column(name = "estado")
    private boolean estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idInsumosDespinche", fetch = FetchType.LAZY)
    private List<DetalleDespinche> detalleDespincheList;

    public InsumosDespinche() {
    }

    public InsumosDespinche(Short id) {
        this.id = id;
    }

    public InsumosDespinche(Short id, int codigo, String nombre, boolean estado) {
        this.id = id;
        this.codigo = codigo;
        this.nombre = nombre;
        this.estado = estado;
    }

    public Short getId() {
        return id;
    }

    public void setId(Short id) {
        this.id = id;
    }

    public int getCodigo() {
        return codigo;
    }

    public void setCodigo(int codigo) {
        this.codigo = codigo;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
    
    public boolean getEstado() {
        return estado;
    }

    public void setEstado(boolean estado) {
        this.estado = estado;
    }

    @XmlTransient
    public List<DetalleDespinche> getDetalleDespincheList() {
        return detalleDespincheList;
    }

    public void setDetalleDespincheList(List<DetalleDespinche> detalleDespincheList) {
        this.detalleDespincheList = detalleDespincheList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof InsumosDespinche)) {
            return false;
        }
        InsumosDespinche other = (InsumosDespinche) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return nombre;
    }

    @Override
    public int compareTo(InsumosDespinche o) {
        String nombre1 = this.getNombre();
        String nombre2 = o.getNombre();
        return nombre1.compareTo(nombre2);
    }
    
}
